﻿import request from '../../../../utils/unirequest';
import type { IPageResponse } from '../../../../type/common';
import type {
  IAddParams,
  IAddResult,
  ISearchResult,
  IGetResult,
} from './interface';

interface ISysActivityParticipationApi {
  search(data: {
    ActivityId: string;
    Limit: number;
    Page: number;
  }): Promise<IPageResponse<ISearchResult[]>>;

  get(id: string | number): Promise<IGetResult>;

  add(data: IAddParams): Promise<IAddResult>;
}

function SysActivityParticipationApi(): ISysActivityParticipationApi {
  return {
    // 获取活动参与列表
    async search(data: {
      ActivityId: string;
      Limit: number;
      Page: number;
    }): Promise<IPageResponse<ISearchResult[]>> {
      return await request.post('/api/SysActivityParticipation/Search', data);
    },
    // 获取活动参与详情
    async get(id: string | number): Promise<IGetResult> {
      return await request.get(`/api/SysActivityParticipation/${id}`);
    },
    // 添加活动参与
    async add(data: IAddParams): Promise<IAddResult> {
      return await request.post('/api/SysActivityParticipation/Add', data);
    },
  };
}

export { SysActivityParticipationApi };
